package com.learning.javaweb_springboot_test.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.learning.javaweb_springboot_test.entity.Student;
import com.learning.javaweb_springboot_test.mapper.StudentMapper;
import com.learning.javaweb_springboot_test.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


//是实现studentService的操作类，得利用mapper接口和数据库打交道

@Service
public class StudentServiceImpl implements StudentService {


    //自动装配mapper接口,前提是mapper接口有加注解
    @Autowired
    StudentMapper studentMapper;

    @Override
    public void addStudent(Student student) {
        studentMapper.insert(student);
    }

    @Override
    public Student queryStudentById(Integer id) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("id", id);
        return studentMapper.selectOne(queryWrapper);
    }


}
